#!/bin/sh

# PROVIDE: gdnsd
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: FreeBSD shutdown

#
# Add the following lines to /etc/rc.conf to enable gdnsd:
# gdnsd_enable (bool):          Set to "NO" by default.
#                               Set it to "YES" to enable gdnsd
# gdnsd_config (str):           Set to "/usr/local/etc/gdnsd/config" by default.
# gdnsd_pidfile (str):		Set to "/usr/local/var/run/gdnsd.pid" by default.

. /etc/rc.subr

name="gdnsd"
rcvar=`set_rcvar`
command="/usr/local/sbin/gdnsd"

# set defaults
load_rc_config $name
: ${gdnsd_enable:="NO"}
: ${gdnsd_config:="/usr/local/etc/gdnsd/config"}
: ${gdnsd_pidfile:="/usr/local/var/run/gdnsd.pid"}

required_files=${gdnsd_config}
command_args="-c ${gdnsd_config} start"
procname=${command}
extra_commands="checkconf"
checkconf_cmd="gdnsd_checkconf"

stop_postcmd=stop_postcmd

stop_postcmd()
{
  rm -f ${gdnsd_pidfile}
}

gdnsd_checkconf()
{
  ${command} -c ${gdnsd_config} checkconf
}

run_rc_command "$1"

